import Cookies from 'js-cookie'

export function getCookie(TokenKey) {
  return Cookies.get(TokenKey)
}

export function setCookie(TokenKey, data) {
  return Cookies.set(TokenKey, data)
}

export function removeCache(TokenKey) {
  return Cookies.remove(TokenKey)
}

// session
export function sessionPut(key, value) {
  // 将对象转化成json字符串，存入sessionStorage
  sessionStorage.setItem(key, JSON.stringify(value))
}

export function sessionGet(key, isRemove) {
  // 从sessionStorage中取出json字符串，然后将json字符串转化成对象,并返回.
  var result = JSON.parse(sessionStorage.getItem(key))
  if (isRemove) {
    sessionStorage.removeItem(key)
  }
  return result
}
